﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Ankha.GUI
{
    public abstract class Component
    {
        //Fields
        public Rectangle ClickRectangle { get; private set; }

        public event EventHandler<ClickEventArgs> OnEventLeftClick = delegate { };
        public event EventHandler<ClickEventArgs> OnEventRightClick = delegate { };
        public event EventHandler<MouseEventArgs> OnEventMouseHover = delegate { };
        
        //ctor
        public Component()
        {

        }

        //Methods
        public virtual void Update(InputControl control, GameTime time)
        {
            if (ClickRectangle.Contains(control.MousePoint))
            {
                OnEventMouseHover(this, new MouseEventArgs());

                if (control.IsLeftClick())
                    OnEventLeftClick(this, new ClickEventArgs());

                if (control.IsRightClick())
                    OnEventLeftClick(this, new ClickEventArgs());
            }
        }
    }
}
